mp_grid_add_rectangle

语法:

mp_grid_add_rectangle(id, x1, y1, x2, y2);


参数 描述
id Index of the mp_grid that is to be used
x1 The x coordinate of the left side of the rectangle to check.
y1 The y coordinate of the top side of the rectangle to check.
x2 The x coordinate of the right side of the rectangle to check.
y2 The x coordinate of the bottom side of the rectangle to check.


返回: N/A(无返回值)


描述

This function asks you to define a rectangle within the room, and then it marks all mp_grid cells "touch" that rectangle as being forbidden, meaning that the path-finding functions cannot cross them. 下图描绘了这是如何工作的:

As you can see, the rectangle defined by (50, 90) to (200, 180) marks all the equivalent mp_grid cells that it touches as being forbidden.


例如:

mp_grid_add_rectangle(grid, 0, 0, 100, 200);

The above code will mark as forbidden all cells of the mp_grid indexed in the variable "grid" that fall within the area 0,0 to 100,200.